#include "GUIManager.h"

template<> GUIManager* Ogre::Singleton<GUIManager>::ms_Singleton = 0;

GUIManager::GUIManager(Ogre::RenderWindow* mWindow) :
	mGUISystem(0),
	mGUIRenderer(0),
	mDefaultSheet(0),
	mRenderWindow(mWindow),
	displayed(false)
{
	// Setup GUI system -- initialize
	Ogre::SceneManager* mSceneMgr = Root::getSingletonPtr()->createSceneManager(ST_GENERIC, "DEF");
	mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
	mGUISystem = new CEGUI::System(mGUIRenderer);
	CEGUI::SchemeManager::getSingleton().loadScheme( (CEGUI::utf8*)"TaharezLookSkin.scheme");

	// Load scheme and set up defaults -- by constructor
	mGUISystem->setDefaultMouseCursor( (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
	mGUISystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");
	CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow");
	// Hide the CEGUI Cursor
	CEGUI::MouseCursor::getSingleton().hide();

	// Align CEGUI mouse with OIS mouse to start at top left of screen
	CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition();  
	CEGUI::System::getSingleton().injectMouseMove(-mousePos.d_x,-mousePos.d_y);

	createIntroGUI();
	createInstructionGUI();
	createOptionsGUI();
	createNetGUI();
	createQuitMenu();
}

GUIManager::~GUIManager()
{
	if(mGUISystem)
		delete mGUISystem;
	if(mGUIRenderer)
		delete mGUIRenderer;
	mGUISystem = 0;
	mGUIRenderer = 0;
}

void GUIManager::registerScene(Ogre::SceneManager* mSceneMgr)
{
	((CEGUI::OgreCEGUIRenderer*)mGUIRenderer)->setTargetSceneManager(mSceneMgr);
}

void GUIManager::setGUISheet(CEGUI::Window* sheet)
{
	mGUISystem->setGUISheet(sheet);
}

bool GUIManager::isDisplayed()
{
	return displayed;
}

void GUIManager::show()
{
	mGUISystem->getGUISheet()->show();
	CEGUI::MouseCursor::getSingletonPtr()->show();
	displayed = true;
}

void GUIManager::hide()
{
	mGUISystem->getGUISheet()->hide();
	CEGUI::MouseCursor::getSingletonPtr()->hide();
	displayed = false;
}

void GUIManager::createIntroGUI()
{
	// Setting up the background window sheet
	CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
    CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Intro/Sheet");
	
	// Create the Play button inside the default sheet
	CEGUI::Window *play = win->createWindow("TaharezLook/Button", "Intro/PlayButton");
    play->setText("Play");
    play->setSize(CEGUI::UVector2(CEGUI::UDim(0.12f, 0), CEGUI::UDim(0.04f, 0)));
	play->setPosition( CEGUI::UVector2(CEGUI::UDim(0.44f,0),CEGUI::UDim(0.65f,0)) );
	sheet->addChildWindow(play);

	// Create the Options button inside the default sheet
	CEGUI::Window *options = win->createWindow("TaharezLook/Button", "Intro/OptionsButton");
    options->setText("Options");
    options->setSize(CEGUI::UVector2(CEGUI::UDim(0.12f, 0), CEGUI::UDim(0.04f, 0)));
	options->setPosition( CEGUI::UVector2(CEGUI::UDim(0.44f,0),CEGUI::UDim(0.72f,0)) );
	sheet->addChildWindow(options);

	// Create the Options button inside the default sheet
	CEGUI::Window *instr = win->createWindow("TaharezLook/Button", "Intro/InstructionButton");
    instr->setText("Instructions");
    instr->setSize(CEGUI::UVector2(CEGUI::UDim(0.12f, 0), CEGUI::UDim(0.04f, 0)));
	instr->setPosition( CEGUI::UVector2(CEGUI::UDim(0.44,0),CEGUI::UDim(0.79f,0)) );
	sheet->addChildWindow(instr);
	
	// Create the Quit button inside the default sheet
	CEGUI::Window *quit = win->createWindow("TaharezLook/Button", "Intro/QuitButton");
    quit->setText("Quit");
    quit->setSize(CEGUI::UVector2(CEGUI::UDim(0.12f, 0), CEGUI::UDim(0.04f, 0)));
	quit->setPosition( CEGUI::UVector2(CEGUI::UDim(0.44f,0),CEGUI::UDim(0.86f,0)) );
	sheet->addChildWindow(quit);
}


void GUIManager::createOptionsGUI()
{
	// Setting up the background window sheet
	CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
    CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Options/Sheet");
	
	// Back button
	CEGUI::Window *back = win->createWindow("TaharezLook/Button", "Options/BackButton");
    back->setText("Back");
	back->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.04f, 0)));
	back->setPosition( CEGUI::UVector2(CEGUI::UDim(0.45f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(back);
	
	// Music 
	CEGUI::Window *music = win->createWindow("TaharezLook/Slider", "Options/Music");
	music->setSize(CEGUI::UVector2(CEGUI::UDim(0.01f, 0), CEGUI::UDim(0.30f, 0)));
	music->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25f,0),CEGUI::UDim(0.2f,0)) );
	sheet->addChildWindow(music);
	CEGUI::Slider *m = static_cast<CEGUI::Slider*> (music);
	m->setMaxValue(1.0);
	m->setClickStep(0.05);
	m->setCurrentValue(0.5);
	
	// Font
	CEGUI::Window *mlbl = win->createWindow("TaharezLook/StaticText", "Options/MusicLabel");
	mlbl->setText("Music");
	mlbl->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	mlbl->setPosition(CEGUI::UVector2(CEGUI::UDim(0.20f,0),CEGUI::UDim(0.1f,0)) );
	sheet->addChildWindow(mlbl);


	// Font
	CEGUI::Window *mfont = win->createWindow("TaharezLook/StaticText", "Options/MusicFont");
	mfont->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	mfont->setPosition(CEGUI::UVector2(CEGUI::UDim(0.20f,0),CEGUI::UDim(0.55f,0)) );
	sheet->addChildWindow(mfont);

	// Sound 
	CEGUI::Window *sound = win->createWindow("TaharezLook/Slider", "Options/Sound");
	sound->setSize(CEGUI::UVector2(CEGUI::UDim(0.01f, 0), CEGUI::UDim(0.30f, 0)));
	sound->setPosition(CEGUI::UVector2(CEGUI::UDim(0.50f,0),CEGUI::UDim(0.2f,0)) );
	sheet->addChildWindow(sound);
	CEGUI::Slider *s = static_cast<CEGUI::Slider*> (sound);
	s->setMaxValue(1.0);
	s->setClickStep(0.05);
	s->setCurrentValue(0.5);
	
	// Font
	CEGUI::Window *slbl = win->createWindow("TaharezLook/StaticText", "Options/SoundLabel");
	slbl->setText("Sound");
	slbl->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	slbl->setPosition(CEGUI::UVector2(CEGUI::UDim(0.45f,0),CEGUI::UDim(0.1f,0)) );
	sheet->addChildWindow(slbl);
		
	// Font
	CEGUI::Window *sfont = win->createWindow("TaharezLook/StaticText", "Options/SoundFont");
	sfont->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	sfont->setPosition(CEGUI::UVector2(CEGUI::UDim(0.45f,0),CEGUI::UDim(0.55f,0)) );
	sheet->addChildWindow(sfont);
	
	// Rounds
	CEGUI::Window *round = win->createWindow("TaharezLook/Slider", "Options/Round");
	round->setSize(CEGUI::UVector2(CEGUI::UDim(0.01f, 0), CEGUI::UDim(0.30f, 0)));
	round->setPosition(CEGUI::UVector2(CEGUI::UDim(0.75f,0),CEGUI::UDim(0.2f,0)) );
	sheet->addChildWindow(round);
	CEGUI::Slider *r = static_cast<CEGUI::Slider*> (round);
	r->setMaxValue(99.0);
	r->setClickStep(1.0);
	r->setCurrentValue(4.0);
		
	// Font
	CEGUI::Window *rlbl = win->createWindow("TaharezLook/StaticText", "Options/RoundLabel");
	rlbl->setText("Rounds");
	rlbl->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	rlbl->setPosition(CEGUI::UVector2(CEGUI::UDim(0.70f,0),CEGUI::UDim(0.1f,0)) );
	sheet->addChildWindow(rlbl);
		
	// Font
	CEGUI::Window *rfont = win->createWindow("TaharezLook/StaticText", "Options/RoundFont");
	rfont->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	rfont->setPosition(CEGUI::UVector2(CEGUI::UDim(0.70f,0),CEGUI::UDim(0.55f,0)) );
	sheet->addChildWindow(rfont);

}

void GUIManager::createInstructionGUI()
{
	// Setting up the background window sheet
	CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
    CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Instruction/Sheet");

	// Back button
	CEGUI::Window *back = win->createWindow("TaharezLook/Button", "Instruction/BackButton");
    back->setText("Back");
	back->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.04f, 0)));
	back->setPosition( CEGUI::UVector2(CEGUI::UDim(0.45f,0),CEGUI::UDim(0.9f,0)) );
	sheet->addChildWindow(back);
	
	// 1P
	CEGUI::Window *o = win->createWindow("TaharezLook/StaticText", "Instruction/OP");
    o->setText("1 P Control");
	o->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	o->setPosition( CEGUI::UVector2(CEGUI::UDim(0.10f,0),CEGUI::UDim(0.2f,0)) );
	sheet->addChildWindow(o);

	CEGUI::Window *w = win->createWindow("TaharezLook/Button", "Instruction/W");
    w->setText("W");
	w->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	w->setPosition( CEGUI::UVector2(CEGUI::UDim(0.15f,0),CEGUI::UDim(0.3f,0)) );
	sheet->addChildWindow(w);
	
	CEGUI::Window *s = win->createWindow("TaharezLook/Button", "Instruction/S");
    s->setText("S");
	s->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	s->setPosition( CEGUI::UVector2(CEGUI::UDim(0.15f,0),CEGUI::UDim(0.4f,0)) );
	sheet->addChildWindow(s);

	CEGUI::Window *a = win->createWindow("TaharezLook/Button", "Instruction/A");
    a->setText("A");
	a->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	a->setPosition( CEGUI::UVector2(CEGUI::UDim(0.15f,0),CEGUI::UDim(0.5f,0)) );
	sheet->addChildWindow(a);

	CEGUI::Window *d = win->createWindow("TaharezLook/Button", "Instruction/D");
    d->setText("D");
	d->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	d->setPosition( CEGUI::UVector2(CEGUI::UDim(0.15f,0),CEGUI::UDim(0.6f,0)) );
	sheet->addChildWindow(d);

	CEGUI::Window *v = win->createWindow("TaharezLook/Button", "Instruction/V");
    v->setText("V");
	v->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	v->setPosition( CEGUI::UVector2(CEGUI::UDim(0.15f,0),CEGUI::UDim(0.7f,0)) );
	sheet->addChildWindow(v);

	CEGUI::Window *b = win->createWindow("TaharezLook/Button", "Instruction/B");
    b->setText("B");
	b->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	b->setPosition( CEGUI::UVector2(CEGUI::UDim(0.15f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(b);	

	// Desc
	CEGUI::Window *des = win->createWindow("TaharezLook/MultiLineEditbox", "Instruction/Desc");
    des->setText("Plitzkrieg is a round-based deathmatch in which two players will battle until death. Players are to move, jump and shoot, as well as using terrain advantages in order to pwn the opponent. The player who pwns the most rounds will pwn the game.");
	des->setSize(CEGUI::UVector2(CEGUI::UDim(0.40f, 0), CEGUI::UDim(0.165f, 0)));
	des->setPosition( CEGUI::UVector2(CEGUI::UDim(0.30f,0),CEGUI::UDim(0.1f,0)) );
	sheet->addChildWindow(des);	

	CEGUI::Window *f = win->createWindow("TaharezLook/StaticText", "Instruction/Forward");
    f->setText("                  Move Forward");
	f->setSize(CEGUI::UVector2(CEGUI::UDim(0.30f, 0), CEGUI::UDim(0.05f, 0)));
	f->setPosition( CEGUI::UVector2(CEGUI::UDim(0.35f,0),CEGUI::UDim(0.3f,0)) );
	sheet->addChildWindow(f);	
	
	CEGUI::Window *ba = win->createWindow("TaharezLook/StaticText", "Instruction/Backward");
    ba->setText("                  Move Backward");
	ba->setSize(CEGUI::UVector2(CEGUI::UDim(0.30f, 0), CEGUI::UDim(0.05f, 0)));
	ba->setPosition( CEGUI::UVector2(CEGUI::UDim(0.35f,0),CEGUI::UDim(0.4f,0)) );
	sheet->addChildWindow(ba);

	CEGUI::Window *l = win->createWindow("TaharezLook/StaticText", "Instruction/Left");
    l->setText("                  Move Left");
	l->setSize(CEGUI::UVector2(CEGUI::UDim(0.30f, 0), CEGUI::UDim(0.05f, 0)));
	l->setPosition( CEGUI::UVector2(CEGUI::UDim(0.35f,0),CEGUI::UDim(0.5f,0)) );
	sheet->addChildWindow(l);

	CEGUI::Window *r = win->createWindow("TaharezLook/StaticText", "Instruction/Right");
    r->setText("                  Move Right");
	r->setSize(CEGUI::UVector2(CEGUI::UDim(0.30f, 0), CEGUI::UDim(0.05f, 0)));
	r->setPosition( CEGUI::UVector2(CEGUI::UDim(0.35f,0),CEGUI::UDim(0.6f,0)) );
	sheet->addChildWindow(r);
	
	CEGUI::Window *shoot = win->createWindow("TaharezLook/StaticText", "Instruction/Shoot");
    shoot->setText("                  Shoot");
	shoot->setSize(CEGUI::UVector2(CEGUI::UDim(0.30f, 0), CEGUI::UDim(0.05f, 0)));
	shoot->setPosition( CEGUI::UVector2(CEGUI::UDim(0.35f,0),CEGUI::UDim(0.7f,0)) );
	sheet->addChildWindow(shoot);

	CEGUI::Window *jump = win->createWindow("TaharezLook/StaticText", "Instruction/Jump");
    jump->setText("                  Jump");
	jump->setSize(CEGUI::UVector2(CEGUI::UDim(0.30f, 0), CEGUI::UDim(0.05f, 0)));
	jump->setPosition( CEGUI::UVector2(CEGUI::UDim(0.35f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(jump);

	// 2P
	CEGUI::Window *t = win->createWindow("TaharezLook/StaticText", "Instruction/TP");
    t->setText("2 P Control");
	t->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.05f, 0)));
	t->setPosition( CEGUI::UVector2(CEGUI::UDim(0.80f,0),CEGUI::UDim(0.2f,0)) );
	sheet->addChildWindow(t);

	CEGUI::Window *ua = win->createWindow("TaharezLook/Button", "Instruction/UpArrow");
    ua->setText("Up");
	ua->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	ua->setPosition( CEGUI::UVector2(CEGUI::UDim(0.80f,0),CEGUI::UDim(0.3f,0)) );
	sheet->addChildWindow(ua);
	
	CEGUI::Window *da = win->createWindow("TaharezLook/Button", "Instruction/DownArrow");
    da->setText("Down");
	da->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	da->setPosition( CEGUI::UVector2(CEGUI::UDim(0.80f,0),CEGUI::UDim(0.4f,0)) );
	sheet->addChildWindow(da);

	CEGUI::Window *la = win->createWindow("TaharezLook/Button", "Instruction/LeftArrow");
    la->setText("Left");
	la->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	la->setPosition( CEGUI::UVector2(CEGUI::UDim(0.80f,0),CEGUI::UDim(0.5f,0)) );
	sheet->addChildWindow(la);

	CEGUI::Window *ra = win->createWindow("TaharezLook/Button", "Instruction/RightArrow");
    ra->setText("Right");
	ra->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	ra->setPosition( CEGUI::UVector2(CEGUI::UDim(0.80f,0),CEGUI::UDim(0.6f,0)) );
	sheet->addChildWindow(ra);

	CEGUI::Window *p = win->createWindow("TaharezLook/Button", "Instruction/P");
    p->setText(".");
	p->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	p->setPosition( CEGUI::UVector2(CEGUI::UDim(0.80f,0),CEGUI::UDim(0.7f,0)) );
	sheet->addChildWindow(p);

	CEGUI::Window *sl = win->createWindow("TaharezLook/Button", "Instruction/Sl");
    sl->setText("/");
	sl->setSize(CEGUI::UVector2(CEGUI::UDim(0.05f, 0), CEGUI::UDim(0.05f, 0)));
	sl->setPosition( CEGUI::UVector2(CEGUI::UDim(0.80f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(sl);	
}

void GUIManager::createNetGUI()
{
	// Creating overlap for the map preview
	// Create image container
	Ogre::OverlayContainer* mSpaceDockContainer = (OverlayContainer*) OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "MapSpaceDock");
	mSpaceDockContainer->setDimensions(300.0f/1072.0f,268.0f/768.0f);
	mSpaceDockContainer->setPosition(0.5f-mSpaceDockContainer->getWidth()/2.0f,142.0f/768.0f);
	mSpaceDockContainer->setMaterialName(MaterialManager::getSingleton().getByName("MapPreview/SpaceDock")->getName());

	Ogre::OverlayContainer* mStoneHengeContainer = (OverlayContainer*) OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "MapStoneHenge");
	mStoneHengeContainer->setDimensions(300.0f/1072.0f,268.0f/768.0f);
	mStoneHengeContainer->setPosition(0.5f-mStoneHengeContainer->getWidth()/2.0f,142.0f/768.0f);
	mStoneHengeContainer->setMaterialName(MaterialManager::getSingleton().getByName("MapPreview/StoneHenge")->getName());

	Ogre::OverlayContainer* mVSContainer = (OverlayContainer*) OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "MapVS");
	mVSContainer->setDimensions(300.0f/1072.0f,268.0f/768.0f);
	mVSContainer->setPosition(0.5f-mVSContainer->getWidth()/2.0f,142.0f/768.0f);
	mVSContainer->setMaterialName(MaterialManager::getSingleton().getByName("MapPreview/VS")->getName());

	// Create the overlay holder
	Ogre::Overlay* mMapHolderOverlay = OverlayManager::getSingletonPtr()->create("MapPreviewOverlay");
	mMapHolderOverlay->setZOrder(648);
    mMapHolderOverlay->add2D(mSpaceDockContainer);
	mMapHolderOverlay->add2D(mStoneHengeContainer);
	mMapHolderOverlay->add2D(mVSContainer);
    mMapHolderOverlay->hide();

	// Setting up the background window sheet
	CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
    CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Net/Sheet");

	// Create color bars
	CEGUI::Window *redSlider = win->createWindow("TaharezLook/HorizontalScrollbar", "Net/P1RedSlider");
	sheet->addChildWindow(redSlider);
	CEGUI::Scrollbar* redBar = static_cast<CEGUI::Scrollbar*>(redSlider);
	redBar->setSize(CEGUI::UVector2(CEGUI::UDim(0.18f, 0), CEGUI::UDim(0.013f, 0)));
	redBar->setPosition(CEGUI::UVector2(CEGUI::UDim(0.14f, 0), CEGUI::UDim(0.6f, 0)));
	redBar->setDocumentSize(256);
	redBar->setPageSize(16);
	redBar->setStepSize(1);
	redBar->setOverlapSize(1);
	redBar->setScrollPosition(0.780535*255);

	CEGUI::Window *grnSlider = win->createWindow("TaharezLook/HorizontalScrollbar", "Net/P1GrnSlider");
	sheet->addChildWindow(grnSlider);
	CEGUI::Scrollbar* grnBar = static_cast<CEGUI::Scrollbar*>(grnSlider);
	grnBar->setSize(CEGUI::UVector2(CEGUI::UDim(0.18f, 0), CEGUI::UDim(0.013f, 0)));
	grnBar->setPosition(CEGUI::UVector2(CEGUI::UDim(0.14f, 0), CEGUI::UDim(0.616f, 0)));
	grnBar->setDocumentSize(256);
	grnBar->setPageSize(16);
	grnBar->setStepSize(1);
	grnBar->setOverlapSize(1);
	grnBar->setScrollPosition(0.346966*255);

	CEGUI::Window *bluSlider = win->createWindow("TaharezLook/HorizontalScrollbar", "Net/P1BluSlider");
	sheet->addChildWindow(bluSlider);
	CEGUI::Scrollbar* bluBar = static_cast<CEGUI::Scrollbar*>(bluSlider);
	bluBar->setSize(CEGUI::UVector2(CEGUI::UDim(0.18f, 0), CEGUI::UDim(0.013f, 0)));
	bluBar->setPosition(CEGUI::UVector2(CEGUI::UDim(0.14f, 0), CEGUI::UDim(0.632f, 0)));
	bluBar->setDocumentSize(256);
	bluBar->setPageSize(16);
	bluBar->setStepSize(1);
	bluBar->setOverlapSize(1);
	bluBar->setScrollPosition(0.155284*255);

	CEGUI::Window *redSlider2 = win->createWindow("TaharezLook/HorizontalScrollbar", "Net/P2RedSlider");
	sheet->addChildWindow(redSlider2);
	CEGUI::Scrollbar* redBar2 = static_cast<CEGUI::Scrollbar*>(redSlider2);
	redBar2->setSize(CEGUI::UVector2(CEGUI::UDim(0.18f, 0), CEGUI::UDim(0.013f, 0)));
	redBar2->setPosition(CEGUI::UVector2(CEGUI::UDim(0.68f, 0), CEGUI::UDim(0.6f, 0)));
	redBar2->setDocumentSize(256);
	redBar2->setPageSize(16);
	redBar2->setStepSize(1);
	redBar2->setOverlapSize(1); 
	redBar2->setScrollPosition(0.371404*255);

	CEGUI::Window *grnSlider2 = win->createWindow("TaharezLook/HorizontalScrollbar", "Net/P2GrnSlider");
	sheet->addChildWindow(grnSlider2);
	CEGUI::Scrollbar* grnBar2 = static_cast<CEGUI::Scrollbar*>(grnSlider2);
	grnBar2->setSize(CEGUI::UVector2(CEGUI::UDim(0.18f, 0), CEGUI::UDim(0.013f, 0)));
	grnBar2->setPosition(CEGUI::UVector2(CEGUI::UDim(0.68f, 0), CEGUI::UDim(0.616f, 0)));
	grnBar2->setDocumentSize(256);
	grnBar2->setPageSize(16);
	grnBar2->setStepSize(1);
	grnBar2->setOverlapSize(1);
	grnBar2->setScrollPosition(0.327496*255);

	CEGUI::Window *bluSlider2 = win->createWindow("TaharezLook/HorizontalScrollbar", "Net/P2BluSlider");
	sheet->addChildWindow(bluSlider2);
	CEGUI::Scrollbar* bluBar2 = static_cast<CEGUI::Scrollbar*>(bluSlider2);
	bluBar2->setSize(CEGUI::UVector2(CEGUI::UDim(0.18f, 0), CEGUI::UDim(0.013f, 0)));
	bluBar2->setPosition(CEGUI::UVector2(CEGUI::UDim(0.68f, 0), CEGUI::UDim(0.632f, 0)));
	bluBar2->setDocumentSize(256);
	bluBar2->setPageSize(16);
	bluBar2->setStepSize(1);
	bluBar2->setOverlapSize(1);
	bluBar2->setScrollPosition(0.757177*255);

	// Create combo box for level selection
	CEGUI::Combobox* mapSelect = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Combobox","Net/MapSelect");
	mapSelect->setPosition(CEGUI::UVector2(CEGUI::UDim(0.4f, 0), CEGUI::UDim(0.6f, 0)));
	mapSelect->setSize(CEGUI::UVector2(CEGUI::UDim(0.2f, 0), CEGUI::UDim(0.11f, 0)));
	mapSelect->setMouseAutoRepeatEnabled(false);
	mapSelect->setProperty("Text","Select Map");
	mapSelect->setReadOnly(true);
    mapSelect->addItem(new CEGUI::ListboxTextItem("Space Dock", 0));
	mapSelect->addItem(new CEGUI::ListboxTextItem("Stonehenge", 1));

	sheet->addChildWindow(mapSelect);
	
	// Create the Start button inside the default sheet
	/*CEGUI::Window *host = win->createWindow("TaharezLook/Button", "Net/HostButton");
    host->setText("Host Game");
    host->setSize(CEGUI::UVector2(CEGUI::UDim(0.15f, 0), CEGUI::UDim(0.06f, 0)));
	host->setPosition( CEGUI::UVector2(CEGUI::UDim(0.175f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(host);*/

	// Create the Start button inside the default sheet
	CEGUI::Window *start = win->createWindow("TaharezLook/Button", "Net/StartButton");
    start->setText("Start");
    start->setSize(CEGUI::UVector2(CEGUI::UDim(0.15f, 0), CEGUI::UDim(0.04f, 0)));
	start->setPosition( CEGUI::UVector2(CEGUI::UDim(0.255f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(start);
	
	// Create the Back button inside the default sheet
	CEGUI::Window *back = win->createWindow("TaharezLook/Button", "Net/BackButton");
    back->setText("Back");
    back->setSize(CEGUI::UVector2(CEGUI::UDim(0.15f, 0), CEGUI::UDim(0.04f, 0)));
	back->setPosition( CEGUI::UVector2(CEGUI::UDim(0.585f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(back);
}

void GUIManager::createQuitMenu()
{
	// Setting up the background window sheet
	CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
    CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Quit/Sheet");
	
	// Create the Start button inside the default sheet
	CEGUI::Window *quit = win->createWindow("TaharezLook/Button", "Quit/QuitButton");
    quit->setText("Quit");
    quit->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.04f, 0)));
	quit->setPosition( CEGUI::UVector2(CEGUI::UDim(0.45f,0),CEGUI::UDim(0.7f,0)) );
	sheet->addChildWindow(quit);
	
	// Create the Back button inside the default sheet
	CEGUI::Window *cancel = win->createWindow("TaharezLook/Button", "Quit/CancelButton");
    cancel->setText("Cancel");
    cancel->setSize(CEGUI::UVector2(CEGUI::UDim(0.10f, 0), CEGUI::UDim(0.04f, 0)));
	cancel->setPosition( CEGUI::UVector2(CEGUI::UDim(0.45f,0),CEGUI::UDim(0.8f,0)) );
	sheet->addChildWindow(cancel);
}